/*
 * $Id: SchedulerTaskDAO.java,v 1.4 2009/07/10 15:18:36 navdeep_mahajan Exp $
 * 
 * Copyright (C) 2009 General Electric Company. All Rights Reserved.
 * 
 * This software is the confidential and proprietary information of the General
 * Electric Company (GE). You shall not disclose this software and shall use it
 * only in accordance with the terms of the license agreement you entered into
 * with GE.
 * 
 * GE MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE
 * SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
 * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
 * NON-INFRINGEMENT. GE SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE
 * AS A RESULT OF USING, MODIFYING, OR DISTRIBUTING THIS SOFTWARE OR ITS
 * DERIVATIVES.
 */
package com.ge.healthcare.autosc.common.database.dao;

import java.util.ArrayList;
import java.util.List;

import com.ge.healthcare.autosc.common.ASCLogger;
import com.ge.healthcare.autosc.common.ASCUtil;
import com.ge.healthcare.autosc.common.database.pojo.CfgSchedulerTask;

/**
 * @author 212042946
 * 
 */
public class SchedulerTaskDAO extends BaseDAO implements ISchedulerTaskDAO {
	/**
	 * Eclipse generated
	 */
	private static final long serialVersionUID = 2480924236467159831L;

	private static final String TABLE_NAME = "com.ge.healthcare.autosc.common.database.pojo.CfgSchedulerTask";

	private static final String COL_SCHEDULER_TASK_ID = "schedulerTaskId";
	private static final String COL_SCHEDULER_TASK_NAME = "taskName";

	public SchedulerTaskDAO() {
		super(TABLE_NAME);
	}

	public CfgSchedulerTask getSchedulerTaskByID(Long schedulerTaskId) {
		Object schedulerTask = findObjectByID(COL_SCHEDULER_TASK_ID,
				schedulerTaskId);
		if (!ASCUtil.isNullOrEmptyObject(schedulerTask)) {
			return (CfgSchedulerTask) schedulerTask;
		}
		return null;
	}

	/**
	 * Find all the scheduler tasks
	 * 
	 * @return
	 */
	public List<CfgSchedulerTask> getAllSchedulerTasks() {
		String queryString = "from " + TABLE_NAME;
		ASCLogger.debug(this.getClass(), "getAllSchedulerTasks",
				new StringBuffer().append(queryString));
		List<?> rtvdSchedulerTasks = getHibernateTemplate().find(queryString);
		if (ASCUtil.isNullOrEmptyList(rtvdSchedulerTasks)) {
			return null;
		}
		List<CfgSchedulerTask> schedulerTaskLst = new ArrayList<CfgSchedulerTask>();
		for (Object schedulerTask : rtvdSchedulerTasks) {
			schedulerTaskLst.add((CfgSchedulerTask) schedulerTask);
		}
		return schedulerTaskLst;
	}

	public CfgSchedulerTask getSchedulerTaskByTaskName(String taskName) {
		Object schedulerTask = findObjectByID(COL_SCHEDULER_TASK_NAME, taskName);
		if (!ASCUtil.isNullOrEmptyObject(schedulerTask)) {
			return (CfgSchedulerTask) schedulerTask;
		}
		return null;
	}

	/**
	 * @see com.ge.healthcare.autosc.common.database.dao.BaseDAO#save(java.lang.Object)
	 */
	public void save(Object pojo) {
		super.save(pojo);
	}

	/**
	 * @see com.ge.healthcare.autosc.common.database.dao.IRequestTypeDAO#saveAlways(java.lang.Object)
	 */
	public void saveAlways(Object pojo) {
		super.save(pojo);
	}

	/**
	 * @see com.ge.healthcare.autosc.common.database.dao.BaseDAO#deleteByID(java.lang.Object)
	 */
	public void deleteByID(Object pojo) {
		super.deleteByID(pojo);
	}

	/**
	 * @see com.ge.healthcare.autosc.common.database.dao.BaseDAO#refresh(java.lang.Object)
	 */
	public void refresh(Object pojo) {
		super.refresh(pojo);
	}
}
